Ext.BLANK_IMAGE_URL = '../ext/resources/images/default/s.gif';
Ext.ux.CorprationList = Ext.extend(Ext.Panel, {
	border:false,
	layout : 'border',
	title:'企业信息列表',
	closable : 'true',
	initComponent : function() {
		var basePath = document.getElementById("basePath").href;
		var corprationListUrl = basePath + 'corpration/list.action?visible=true';
		var limit = 20;
	
		var corprationStore = new Ext.data.Store({
			storeId:'corprationStore',
			proxy:new Ext.data.HttpProxy({url: corprationListUrl}),
		    reader : new Ext.data.JsonReader({
			    idProperty: 'id',       
			    root: 'corprationList',
			    totalProperty: 'corprationTotal',
			    remoteSort: true,
			    
			    fields: [
			        {name: 'id', mapping:'id', type:'int'},
			        {name: 'address', mapping:'address', type:'string'},
			        {name: 'email', mapping:'email', type:'string'},
			        {name: 'fax', mapping:'fax', type:'string'},
			        {name: 'telephone', mapping:'telephone', type:'string'},
			        {name: 'zipcode', mapping:'zipcode', type:'string'},
			        {name: 'lang', mapping:'lang', type:'string'},
			        {name: 'createDate', mapping:'createDate', type:'string'}
			    ]    
			})
		});
		
		this.items = [ {
			xtype : 'grid',
			title : '企业信息列表',
			id : 'corprationDataGrid',
			region : 'center',
			split : true,
			frame : true,
			loadMask: true,
			sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
			autoScroll:true,
			ds : corprationStore,
			columns : [ {
				xtype : 'gridcolumn',
				dataIndex : 'id',
				header : '序号',
				sortable : true,
				width : 40
			}, {
				xtype : 'gridcolumn',
				dataIndex : 'address',
				header : '企业地址',
				sortable : true,
				width : 160,
				align : 'left'
			}, {
				xtype : 'gridcolumn',
				dataIndex : 'email',
				header : '企业邮箱',
				sortable : true,
				width : 100
			}, {
				xtype : 'gridcolumn',
				dataIndex : 'fax',
				header : '企业传真',
				sortable : true,
				width : 100
			}, {
				xtype : 'gridcolumn',
				dataIndex : 'telephone',
				header : '企业电话',
				sortable : true,
				width : 100
			}, {
				xtype : 'gridcolumn',
				dataIndex : 'zipcode',
				header : '企业邮编',
				sortable : true,
				width : 100
			}, {
				xtype : 'gridcolumn',
				dataIndex : 'zipcode',
				header : '企业邮编',
				sortable : true,
				width : 100
			}, {
				xtype : 'gridcolumn',
				dataIndex : 'lang',
				header : '语言',
				sortable : true,
				width : 100
			}, {
				xtype : 'gridcolumn',
				dataIndex : 'createDate',
				header : '添加日期',
				sortable : true,
				width : 140
			}],
			bbar: new Ext.PagingToolbar({
	            pageSize: limit,
	            store: corprationStore,
	            beforePageText:"当前第",   
	            afterPageText:"页，共{0}页",   
	            lastText:"尾页",   
	            nextText :"下一页",   
	            prevText :"上一页",   
	            firstText :"首页",   
	            refreshText:"刷新页面",   
	            displayInfo: true,
	            displayMsg: '显示第 {0} 条到 {1} 条记录，共 {2} 条',
	            emptyMsg: "没有记录"
	        }),
	        tbar:[{
	        	text:'修改',
	        	tooltip:'Modify A Record',
	        	iconCls:'modify',
	        	handler:function() {
	        		var linenum = Ext.getCmp("corprationDataGrid").getSelectionModel().lastActive;
	        		if(getType(linenum) == "number") {
		        		new Ext.ux.ModifyCorpration({id:'modifyCorprationWin'}).show(this);
	        		} else {
	        			Ext.Msg.alert('警告', '未选中任何行');
	        		}
	        	}
	        }, '-', {
	        	text:'查看',
	        	tooltip:'View A Record',
	        	iconCls:'open',
	        	handler:function() {
	        		var linenum = Ext.getCmp("corprationDataGrid").getSelectionModel().lastActive;
	        		if(getType(linenum) == "number") {
		        		new Ext.ux.ViewCorpration({idString:'corprationDataGrid'}).show(this);
	        		} else {
	        			Ext.Msg.alert('警告', '未选中任何行');
	        		}
	        	}
	        }]
		} ];
		Ext.ux.CorprationList.superclass.initComponent.call(this);
		corprationStore.load({params:{start:0, limit:limit}});
	}
});
Ext.reg('lgnCorprationList', Ext.ux.CorprationList);